package com.softstao.guoyu.mvp.presenter.me;

import com.softstao.guoyu.model.me.AddressCondition;
import com.softstao.guoyu.model.me.AddressList;
import com.softstao.guoyu.model.me.AreaList;
import com.softstao.guoyu.mvp.interactor.me.AddressInteractor;
import com.softstao.guoyu.mvp.presenter.BasePresenter;
import com.softstao.guoyu.mvp.viewer.BaseViewer;
import com.softstao.guoyu.mvp.viewer.LinkProvinceCityViewer;
import com.softstao.guoyu.mvp.viewer.me.AddressListViewer;
import com.softstao.guoyu.mvp.viewer.me.AddressViewer;

/**
 * Created by vaikus on 2017/6/22.
 */

public class AddressPresenter extends BasePresenter<BaseViewer,AddressInteractor> {
    public void getAddress(int agentId){
        interactor.getAddress(agentId,o -> ((AddressListViewer)viewer).getList((AddressList) o));
    }

    public void changeDefault(int agentId, int addressId){
        interactor.changeDefault(agentId,addressId,o -> ((AddressListViewer)viewer).changeResult((AddressList) o));
    }

    public void deleteAddress(int agentId, int addressId){
        interactor.deleteAddress(agentId,addressId,o -> ((AddressListViewer)viewer).deleteResult(o));
    }

    public void addAddress(AddressCondition condition){
        interactor.addAddress(condition,o -> ((AddressViewer)viewer).addResult((AddressList) o));
    }

    public void getArea(String provinceCode){
        interactor.getArea(provinceCode,o -> ((LinkProvinceCityViewer)viewer).getResult((AreaList) o));
    }
}
